/**
 * Created by asus on 2017/5/7. ������
 */
require(["jquery", "template", "bbcare", "bootstrap3.min", "bootstrap-datetimepicker.min", "bdCN", "scprit/department/view/template/allPatients-js.js"], function ($, template, $bb, bootstrap, bd, bdCN, tpl) {
    var URL = $bb.baseUrl("department") + "followup/service";
    var templateId = $bb.getPageParams();//��ȡ���ݹ����Ĳ���
    //��������
    $bb.ajax({
        url: URL + "/education/template/detail",
        type: "post",
        contentType: "application/json;charset=UTF-8",
        dataType: "json",
        data: JSON.stringify({
            data: {
                "templateId": templateId
            }
        }),
        success: function (data) {
            var a = JSON.parse(data.data.templateParam);
            $(".moban").html(data.data.templateContent);
            $("#title").val(a.title);
            $("#con").val(a.content);
            $(".templates b").html(a.title);
            $(".templates div").html(a.content)
            $(".btn11").html(data.data.templateName);
            $(".moban div").css("width", "192px");
        },
        error: function (data) {
            console.log('�������' + data);
        }
    });
    //������ת
    $("#save").click(function () {
        var title = $("#title").val();
        var con = $("#con").val();
        var temp = {};
        temp.title = title;
        temp.content = con;
        var str = JSON.stringify(temp);
        $(".templates b").html(title);
        $(".templates div").html(con);
        var html = $(".moban").html();
        $bb.ajax({
            url: URL + "/education/modify",
            type: "post",
            contentType: "application/json;charset=UTF-8",
            dataType: "json",
            data: JSON.stringify({
                data: {
                    "templateId": templateId,
                    "isTop": 0,
                    "content": html,
                    "title": title,
                    "templateValue": str,
                }
            }),
            success: function (data) {
                $bb.selectNavbar("missionManagement");
            },
            error: function (data) {
                console.log('�������' + data);
            }
        });
    })

});